var tableData = {
	url : ctp + "/exitSettlementController/getExitPayApplyWorker.shtml?applyId=" + recId,
	propertys : [ "WORKER_NAME","JOBNO","GROUP_NAME","SALARY","CHARGETYPE","UNITPAY","PAYFORM","TOTAL_TIME","TOTAL_SHOULD_PAY","TOTAL_REAL_PAY","TOTAL_NOT_PAY","REJECT_STATE"],
	checkBox:["REC_ID",false],
	opers : false,
	startLoad : function() {
		getListData(this);
	}
};
function searchData(curr) {
	setTagAndValue("form1", "curr", curr);
	setTagAndValue("form1","SUNNADA_PAGE_SIZE",5); 
	tableData.checkBoxValue = window.parent.$("#workerId").val();
	tableData.startLoad();
}

$(document).ready(function() {
	getExitPayApply();
	searchData();
	getProcessCondition();
});

//获取申请单基本信息
function getExitPayApply(){
	$.ajax({ 
	 	url: ctp + "/exitSettlementController/getExitPayApplyByRecid.shtml",
	 	data: {"recId": recId,"auditId": auditId},
		type : 'POST',
		dataType: "json", 
		success : function(result) {
			if(result != null){
				var list = result.list;
				var data = list[0];
				$("#applyTime").val(data.APPLY_TIME_CHAR);
				$("#applyPerson").val(data.USER_NAME);
				if(data.AUDIT_STATE == '1' || data.AUDIT_STATE == '2'){
					$("#auditButton").hide();
					$("#auditDesc").val(data.AUDIT_DESC);
				}
			}
		}
	});
}

//获取当前流程审核情况
function getProcessCondition(){
	$.ajax({ 
	 	url: ctp + "/processController/getProcessConditionByrecid.shtml",
	 	data: {"recId": recId,"isView":"2","processType":"exitPayApply"},
		type : 'POST',
		dataType: "json", 
		success : function(result) {
			if(result != null){
				var list = result.list;
				for(var i = 0; i < list.length; i++){
					var data = list[i];
					if(data.PARENT_ID == "00"){
						addProcessContionView(data);
					}
				}
				var parentId = '0';
				iterateProcess(list, parentId);
				
				//完成节点
				completeHtml();
			}
		}
	});
}

//循环遍历审批流程
function iterateProcess(list, parentId){
	for(var i = 0; i < list.length; i++){
		if(list[i].PARENT_ID == parentId){
			addProcessContionView(list[i]);
			iterateProcess(list, list[i].AUDIT_ID);
		}
	}
}



function audit(value){
	$.ajax({ 
	 	url: ctp + "/exitSettlementController/audit.shtml",
	 	data: {"auditId": auditId,"auditState": value,"submitId": recId,"auditDesc": $("#auditDesc").val()},
		type : 'POST',
		success : function(result) {
			if(result == ''){
				jalert9("审核成功！");
			}else{
				jalert(result);
			}
		}
	});
}